# SmartNexus主程序

import logging
from src.database.data_manager import DataManager
from src.stock.stock_manager import StockManager
from src.strategy.strategy_manager import StrategyManager
from src.utils.logger_manager import log, err

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

def main():
    """主函数，获取并展示A股所有股票数据，并将数据存储到数据库中"""
    try:
        # 获取管理器实例
        DataManager.get_instance()
        stock_manager = StockManager.get_instance()
        # 初始化股票管理器
        if not stock_manager.initialize():
            logger.error("股票管理器初始化失败")
            return
        # 初始化策略管理器
        strategy_manager = StrategyManager.get_instance()
        logger.info("系统初始化完成")
        stock_manager.run_daily_update()
        # strategy_manager.run_strategy('dragon_repair')
    except Exception as e:
        logger.error(f"程序执行出错: {str(e)}")
        return

if __name__ == "__main__":
    main()